<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>


    // 让异步操作（promise 或者 async）等待一段时间
    // (async () => {
    // console.log('hi')
    // await wait(2000) // 等待两秒
    // console.log('xiaoming')
    // })()
    // @param time
    // / const wait = (time) => {
    // }

    const wait = (time) => {
      let p1 = new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve();
        }, time);
      })

      return p1
    }

    (async () => {
      console.log('hi')
      await wait(2000) // 等待两秒
      console.log('xiaoming')
    })()

  </script>
</body>

</html>